package top.kaoshanji.p2ch09a;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 * 代码清单-p2ch09a-289页a：查看类加载器的层次结构的示例
 * author kaoshanji
 * ^_^
 * create time 2025/1/28 10:20
 */
public class ClassLoaderParent {

    private static final Logger logger = LogManager.getLogger(ClassLoaderParent.class);

    public static void main(String[] args) {
        logger.info("...代码清单-p2ch09a-289页a：查看类加载器的层次结构的示例...");

        ClassLoaderParent example = new ClassLoaderParent();
        example.displayParents();

    }

    public void displayParents() {
        ClassLoader current = getClass().getClassLoader();
        while (null != current) {
            logger.info("...类加载器的名字：{}...", current.toString());
            current = current.getParent();
        }
    }



}
